import 'package:appinio_video_player/appinio_video_player.dart';
import 'package:get/get_rx/src/rx_types/rx_types.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';

class MyVideoPlayerController extends GetxController {
  RxList<VideoPlayerController> imageVideoDetailEntity = RxList();
  int current = 0;

  void setCurrent() {
    if(current == 3) {
      current = current % 3;
  } else {
      current = current + 1;
    }
  }
  VideoPlayerController getCurrent() {
   return this.imageVideoDetailEntity[current-1];
  }
  Future<void> addVideoPlayerController(VideoPlayerController videoPlayerController) async {
    if(imageVideoDetailEntity.length == 3) {
      this.imageVideoDetailEntity.add(videoPlayerController);

    } else {
      this.imageVideoDetailEntity[current].dispose();
      this.imageVideoDetailEntity[current] = videoPlayerController;
    }
    await this.imageVideoDetailEntity[current].initialize();
    this.imageVideoDetailEntity[current].setLooping(true);
  }

}